사이트 내 전체검색
vnst vnstat 설치 / 설정
프리이미지
https://cmd.kr/server/952 URL이 복사되었습니다.

본문

tar xfvj vnst.bz2

apt-get install -y vnstat

ifconfing 한 네트워크 디바이스 (eth0) 넣는다.

vnstat -u -i eno1

or

vnstat -u -i eth0

 

 

2일전 바뀐 파일

find / -used 2 -exec ls -l {} \; > /nfs/change.txt

 

 

특정날짜에 만들어진 파일 찾기  2016-05-31 14:00 ~ 2016-05-31 21:00 

--> 이 방법을 이용하면 지정한 날짜와 시간에 생성된 파일이 만들어짐

 

 2. 위에서 만든 파일을 가지고 파일 검색

 

mkdir /nfs/tmp

touch 201605311400 /nfs/tmp/start.txt

touch 201605312100 /nfs/tmp/end.txt

find / -newer /nfs/tmp/start.txt -a ! -newer /nfs/tmp/end.txt -ls

--> 7월1일 ~2일 사이에 생성된 파일을 검색하여 /data/backup으로 복사하라

 

[출처] [Linux] find 명령어 사용법, 특정기간동안 만들어진 파일 찾기|작성자 juner84

 

 

apt-get install -y libapache2-mod-perl2

apt-get install -y awstats libgeoip1 libgeoip-dev libgeo-ip-perl

cd /etc/awstats

vi /etc/awstats/awstats.conf

 

 

123번째줄 : LogFormat=4 를 LogFormat=1 로 변경. ubuntu apache 기본값이 1번입니다.

154번째줄 : SiteDomain=”” 를 SiteDomain=”mydomain.com” 로 변경. 작업중인 파일명을 참고하여 변경하세요.

168번째줄 : HostAliases=”localhost 127.0.0.1” 를 HostAliases=mydomain.com localhost 127.0.0.1” 로 변경. 현재 설정파일과 동일하게 취급할 도메인을 띄어쓰기를 구분자로 하여 적어줍니다.

188번째줄 : DNSLookup=1 을 DNSLookup=0 으로 변경. dnslookup 은 부하가 많이 걸리므로 꺼두는게 좋습니다.

905번째줄 : Lang=”auto” 를 Lang=”ko” 로 변경. 강제로 한국어를 지정합니다. awstats에는 한글UI를 지원합니다.

 

 

Plugin 활성화

LoadPlugin="tooltips" 

LoadPlugin="geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat"

LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/share/GeoIP/GeoIPCity.dat"

 

 

 

cp awstats.conf awstats.localhost.conf

mv awstats.conf awstats.conf_

 

 

apt-get install -y libgeoip1 libgeoip-dev libgeo-ip-perl

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

gzip -d GeoLiteCity.dat.gz

mv GeoLiteCity.dat /usr/share/GeoIP/

chown root.root /usr/share/GeoIP/GeoLiteCity.dat

cp -rf /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat

 

 

 

 

vi /etc/apache2/sites-enabled/awstats.conf

 

## -- awstats 설정 ##

Alias /awstatsclasses "/usr/share/awstats/lib/"

Alias /awstats-icon/ "/usr/share/awstats/icon/"

Alias /awstatscss "/usr/share/doc/awstats/examples/css"

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

ScriptAlias /awstats/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">

    AllowOverride None

    Require all granted

    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

    Order allow,deny

    #Allow from all

    Allow from xxx.xxx.xxx.89/255.255.255.0

</Directory>

 

 

ln -s /etc/apache2/mods-available/cgid.* /etc/apache2/mods-enabled/

service apache2 restart

 

 

 

4) crontab

매시 30분 마다 로그 정보를 분석하여 update

$ sudo crontab -e

30 * * * * /usr/lib/cgi-bin/awstats.pl -config=localhost -update > /dev/null

 

 

 

4. 과거 로그 파일 처리하기

 

저의 경우에는 logrotate가 설치되어 있기에, 과거 gz로 압축된 로그들을 처리해야 했습니다. 다음과 같은 명령어를 통해 간단하게 과거의 로그들을 하나로 통합해서 분석할 수 있습니다.

 

이 때 주의할 점은, awstats는 가장 마지막으로 parse된 파일 이후의 것만 처리하기 때문에 과거 로그를 먼저 import 한 다음에 최신 로그를 처리해야 한다는 것입니다. 즉 4번 단계를 먼저 하고 5번 단계를 하시면 되며, 과거 쌓인 내역이 없거나 분석하기 원치 않으시는 경우에는 바로 5번 단계로 넘어가시면 됩니다.

 

 

cd /var/log/apache2

gzip -d /var/log/apache2/access.log.*.gz

 

/usr/share/awstats/tools/logresolvemerge.pl access.log.* >> /var/log/apache2/access_combined.log

/usr/lib/cgi-bin/awstats.pl -config=localhost -LogFile="/var/log/apache2/access_combined.log"

 

 

 

gzip -d /var/log/apache2/w.access.log.*.gz

 

/usr/share/awstats/tools/logresolvemerge.pl w.access.log.* >> /var/log/apache2/w.access_combined.log

/usr/lib/cgi-bin/awstats.pl -config=localhost -update -LogFile="/var/log/apache2/w.access_combined.log"

/usr/lib/cgi-bin/awstats.pl -config=localhost -update -LogFile="/var/log/apache2/w.access.log"

 

gzip -d /var/log/apache2/other*access.log.*.gz

/usr/share/awstats/tools/logresolvemerge.pl /var/log/apache2/other*access.log.* >> /var/log/apache2/other.access_combined.log

/usr/lib/cgi-bin/awstats.pl -config=azo.co.kr -update -LogFile="/var/log/apache2/other.access_combined.log"

/usr/lib/cgi-bin/awstats.pl -config=azo.co.kr -update -LogFile="/var/log/apache2/other_vhosts_access.log"

 

 

 

awstats 초기화

rm -f /var/lib/awstats/*.txt

데이터 경로는  *.conf 파일에 명시됨

DirData="/var/lib/awstats"

 

 

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\"%{ <-- HERE Referer}i\"/ at /usr/lib/cgi-bin/awstats.pl line 9043.

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\"%{ <-- HERE User-Agent}i\"/ at /usr/lib/cgi-bin/awstats.pl line 9044.

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE mod_gzip_input_size}n/ at /usr/lib/cgi-bin/awstats.pl line 9045.

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE mod_gzip_output_size}n/ at /usr/lib/cgi-bin/awstats.pl line 9046.

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE mod_gzip_compression_ratio}n/ at /usr/lib/cgi-bin/awstats.pl line 9047.

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\(%{ <-- HERE ratio}n\)/ at /usr/lib/cgi-bin/awstats.pl line 9048.

 

오류나올때는 

해당 라인의 { 앞에 \ 를 넣어줄것

 

$LogFormatString =~ s/\"%\{Referer}i\"/%refererquot/g;

$LogFormatString =~ s/\"%\{User-Agent}i\"/%uaquot/g;

$LogFormatString =~ s/%\{mod_gzip_input_size}n/%gzipin/g;

$LogFormatString =~ s/%\{mod_gzip_output_size}n/%gzipout/g;

$LogFormatString =~ s/%\{mod_gzip_compression_ratio}n/%gzipratio/g;

$LogFormatString =~ s/\(%\{ratio}n\)/%deflateratio/g;

 

댓글목록

등록된 댓글이 없습니다.

1,139 (2/23P)

Search

Copyright © Cmd 명령어 18.217.120.217